function Watcher (vm, exp, cb) {
    this.cb = cb
    this.vm = vm
    this.exp = exp
    this.depIds = {}
    this.value = this.get()
}

Watcher.prototype = {
    update: function () {
        this.value = this.get()
        this.cb.call(this.vm, this.value)
    },
    get: function () {
        Dep.target = this
        let val = this.getVMVal()
        Dep.target = null
        return val
    },
    addDep: function (dep) {
        if (!this.depIds.hasOwnProperty(dep.id)) {
            dep.addSub(this)
            this.depIds[dep.id] = dep
        }
    },
    getVMVal: function () {
        let exp = this.exp.split('.');
        let val = this.vm._data;
        exp.forEach(function (k) {
            val = val[k];
        });
        return val;
    }
}